Crate imxrt_dma

source ·
Expand description

Direct Memory Access (DMA) driver for i.MX RT processors.

imxrt-dma provides

  • an unsafe API for defining and scheduling transfers with DMA Channels.
  • safe DMA futures for memcpy, peripheral-to-memory, and memory-to-peripheral transfers.

This DMA driver may be re-exported from a hardware abstraction layer (HAL). If it is, you should use the safer APIs provided by your HAL.

Getting started

To allocate a Dma driver, you’ll need to know

  1. the location of the DMA controller registers.
  2. the location of the DMAMUX registers.
  3. the number of DMA channels supported by your chip.

These parameters depend on the i.MX RT chip you’re targeting. If you’re already using imxrt-ral, consider using the DMA and DMAMUX constants for the addresses. You’re always responsible for configuring the number of DMA channels.

With those three parameters, assign a Dma to a static. Then, use that object to create DMA Channels.

use imxrt_dma::Dma;

// Safety: addresses and channel count are valid for this target.
static DMA: Dma<32> = unsafe { Dma::new(DMA_PTR, DMAMUX_PTR) };

// Safety: we only allocate one DMA channel 7 object.
let mut channel = unsafe { DMA.channel(7) };

Once you have a channel, you can use the higher-level DMA APIs, like

  • memcpy for memory copies.
  • write to transmit data from memory to a peripheral.
  • read to receive data from a peripheral.
  • full_duplex to read / write with a peripheral using a single buffer.

Peripheral transfers depends on a peripheral’s DMA support. These are signaled through various peripheral traits.

For a lower-level API, use the channel objects and helper functions.

License

Licensed under either of

at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Modules

DMA channels
DMA-powered memcpy
DMA support for hardware peripherals.

Structs

A DMA driver.
A wrapper around a DMA error status value
The core DMA transfer future

Enums

Throttles the amount of bus bandwidth consumed by the eDMA

Traits

Describes a transferrable DMA element; basically, an unsigned integer of any size.

Type Definitions

A DMA result